// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sys

import (
	"context"
	"hotgo/api/admin/hotmatch"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	Hotmatch = cHotmatch{}
)

type cHotmatch struct{}

// List 查看热门赛事列表
func (c *cHotmatch) List(ctx context.Context, req *hotmatch.ListReq) (res *hotmatch.ListRes, err error) {
	list, totalCount, err := service.SysHotmatch().List(ctx, &req.HotmatchListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.HotmatchListModel{}
	}

	res = new(hotmatch.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新热门赛事
func (c *cHotmatch) Edit(ctx context.Context, req *hotmatch.EditReq) (res *hotmatch.EditRes, err error) {
	err = service.SysHotmatch().Edit(ctx, &req.HotmatchEditInp)
	return
}

// MaxSort 获取热门赛事最大排序
func (c *cHotmatch) MaxSort(ctx context.Context, req *hotmatch.MaxSortReq) (res *hotmatch.MaxSortRes, err error) {
	data, err := service.SysHotmatch().MaxSort(ctx, &req.HotmatchMaxSortInp)
	if err != nil {
		return
	}

	res = new(hotmatch.MaxSortRes)
	res.HotmatchMaxSortModel = data
	return
}

// View 获取指定热门赛事信息
func (c *cHotmatch) View(ctx context.Context, req *hotmatch.ViewReq) (res *hotmatch.ViewRes, err error) {
	data, err := service.SysHotmatch().View(ctx, &req.HotmatchViewInp)
	if err != nil {
		return
	}

	res = new(hotmatch.ViewRes)
	res.HotmatchViewModel = data
	return
}

// Delete 删除热门赛事
func (c *cHotmatch) Delete(ctx context.Context, req *hotmatch.DeleteReq) (res *hotmatch.DeleteRes, err error) {
	err = service.SysHotmatch().Delete(ctx, &req.HotmatchDeleteInp)
	return
}